﻿
<div class="ld-tabs">
    <ul>
        <li class="k-state-active">仓库列表</li>
    </ul>
    <div>
        <div class="k-block divToolbar">
            <button class="k-button" onclick="CreateNewWarehouse()"><span class="k-icon k-i-plus"></span><span>添加新仓库</span></button>
        </div>
        <div id="grid_warehouse" style="text-align: center"></div>
    </div>
</div>

<script class="grid_warehouse_columns">
    var warehouseFields = [{
        title: "#",
        field: "ID",
        width: 50
    }, {
        title: "仓库名称",
        field: "House",
        width: 200
    
    }, {
        title: "操作",
        template: "#=GetOperations(ID)#",
        attributes: { style: "text-align:left" }
    }];

    function GetOperations(id) {
        var html = "<button class='k-button' onclick=\"EditWarehouse(" + id + ")\"><span class='k-icon k-i-pencil'></span><span>修改</span></button>";
        
        return html;
    }

    function EditWarehouse(id) {
        if (wndGeneralEdit != null && typeof wndGeneralEdit != "undefined") {
            wndGeneralEdit.setOptions({ title: "修改仓库信息" });
            wndGeneralEdit.refresh({ url: "/Orders/Warehouse/Edit/" + id });
            wndGeneralEdit.open();
        }
    }

   

</script>

<script class="grid_config">
    $(function () {
        $("#grid_warehouse").kendoGrid({
            columns: warehouseFields,
            dataSource: Whale.dataSource({
                url: "/Orders/Warehouse/Gets"
                
            }),
            pageable: {
                messages: {
                    empty: "暂无数据"
                }
            },
            dataBound: function (e) {
                //让表头居中
                $("th.k-header").attr("style", "text-align:center; font-weight:bold;");
            }
        });
    });

    function CreateNewWarehouse() {
        wndGeneralEdit.setOptions({ title: "添加新的仓库" });
        wndGeneralEdit.refresh({ url: "/Orders/Warehouse/Edit" });
        wndGeneralEdit.open();
    }

    
</script>